<?xml version="1.0" encoding="UTF-8"?>

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<!--
    Ignite Spring configuration file to startup grid cache.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util.xsd">
    <bean abstract="true" id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="localHost" value="127.0.0.1"/>
        <property name="connectorConfiguration"><null/></property>

        <property name="clientConnectorConfiguration">
            <bean class="org.apache.ignite.configuration.ClientConnectorConfiguration">
                <property name="host" value="127.0.0.1"/>
                <property name="port" value="11110"/>
                <property name="portRange" value="10"/>
            </bean>
        </property>

        <property name="includeEventTypes">
            <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
        </property>

        <property name="cacheConfiguration">
            <list>
                <bean parent="test-type-template"/>
            </list>
        </property>

        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <!-- In distributed environment, replace with actual host IP address. -->
                                <value>127.0.0.1:47500..47503</value>
                            </list>
                        </property>
                    </bean>
                </property>
                <property name="socketTimeout" value="300" />
            </bean>
        </property>

        <property name="transactionConfiguration">
            <bean class="org.apache.ignite.configuration.TransactionConfiguration">
                <property name="txSerializableEnabled" value="true"/>
            </bean>
        </property>
    </bean>

    <bean id="test-type-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
        <property name="name" value="cacheAllFields"/>
        <property name="writeSynchronizationMode" value="FULL_SYNC"/>
        <property name="cacheMode" value="PARTITIONED"/>
        <property name="atomicityMode" value="TRANSACTIONAL"/>

        <property name="affinity">
            <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
                <property name="partitions" value="256"/>
            </bean>
        </property>

        <!-- Configure type metadata to enable queries. -->
        <property name="queryEntities">
            <list>
                <bean class="org.apache.ignite.cache.QueryEntity">
                    <property name="keyType" value="java.lang.Long"/>
                    <property name="valueType" value="TestType"/>

                    <property name="fields">
                        <map>
                            <entry key="i8Field" value="java.lang.Byte"/>
                            <entry key="i16Field" value="java.lang.Short"/>
                            <entry key="i32Field" value="java.lang.Integer"/>
                            <entry key="i64Field" value="java.lang.Long"/>
                            <entry key="strField" value="java.lang.String"/>
                            <entry key="floatField" value="java.lang.Float"/>
                            <entry key="doubleField" value="java.lang.Double"/>
                            <entry key="boolField" value="java.lang.Boolean"/>
                            <entry key="guidField" value="java.util.UUID"/>
                            <entry key="dateField" value="java.util.Date"/>
                            <entry key="timeField" value="java.sql.Time"/>
                            <entry key="timestampField" value="java.sql.Timestamp"/>
                            <entry key="i8ArrayField" value="[B"/>
                        </map>
                    </property>

                    <property name="keyFields">
                        <list></list>
                    </property>

                    <property name="indexes">
                        <list>
                            <bean class="org.apache.ignite.cache.QueryIndex">
                                <constructor-arg value="i32Field"/>
                            </bean>
                            <bean class="org.apache.ignite.cache.QueryIndex">
                                <constructor-arg value="i64Field"/>
                            </bean>
                        </list>
                    </property>
                </bean>
            </list>
        </property>
    </bean>
</beans>
